home *** CD-ROM | disk | FTP | other *** search
- Path: news.dfn.de!si-nic!usenet
- From: Markus Becker <becker@zess.uni-siegen.de>
- Newsgroups: comp.lang.c
- Subject: Re: Best way to make a circle
- Date: Fri, 09 Feb 1996 11:14:06 +0100
- Organization: ZESS, Uni-GH-Siegen
- Message-ID: <311B1E6E.6809@zess.uni-siegen.de>
- References: <1996Feb8.043040.19301@lafn.org>
- NNTP-Posting-Host: becker.zess.uni-siegen.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Andres Lessing wrote:
- >
- > I am working on 3d Graphics quite succesfully as of now and am trying to
- > put together a good Graphics library that is much faster than BGI drivers.
- > I know that Sin and Cosine take to much time to calculate... so... which
- > way should I do it?
-
- Do it Bresenham's way:
-
- -------------- cut here -------------
- void DrawCircle(int xm, int ym, int r, COLOR color)
- {
- register int x,y, d;
-
- d = r - 1;
-
- x = 0;
- y = r;
-
- while (x<=y)
- {
- if (d < 0)
- {
- y--;
- d += (y + y);
- }
-
- DrawPixel(xm+x, ym+y, color);
- DrawPixel(xm+x, ym-y, color);
- DrawPixel(xm-x, ym+y, color);
- DrawPixel(xm-x, ym-y, color);
-
- DrawPixel(xm+y, ym+x, color);
- DrawPixel(xm+y, ym-x, color);
- DrawPixel(xm-y, ym+x, color);
- DrawPixel(xm-y, ym-x, color);
-
- d -= (x + x + 1);
- x++;
- }
-
- } /* DrawCircle */
-
- ---------------- cut here --------------
- --
- Markus Becker http://www.zess.uni-siegen.de/private/becker/
- Zentrum fuer Sensorsysteme (ZESS)
- http://www.zess.uni-siegen.de/private/becker/win95
-